#!/usr/bin/env ruby

def usage 
    $stderr.puts "USAGE: #{File.basename($0)} <file> <size>"
    $stderr.puts "-"*40
    $stderr.puts " file    The file to pad with zero bytes"
    $stderr.puts " size    The total size in bytes to pad file to*"
    $stderr.puts
    $stderr.puts "(*) If file is already size or more bytes it is not changed"
    $stderr.puts
    $stderr.puts "Output is modified file contents"
    exit 42
end

file_in = ARGV.shift || usage
out_size = (ARGV.shift || usage).to_i
contents = File.new(file_in, "rb").read
if contents.size < out_size
    contents += '0'*(out_size - contents.size)
end
print contents
